﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Com.CMS263.BLL;
using Com.CMS263.PO;
using Com.CMS263.Util;
using System.Collections.Generic;

namespace Com.CMS263.Web.manage
{
    public partial class modArtType : System.Web.UI.Page
    {
        public string ap = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            string id = Request["id"];
            this.hdfpid.Value = id;
            if (!this.IsPostBack)
            {
                this.Bind(int.Parse(id));
                this.BindList();
            }

        }

        void BindList()
        {
            IList<AttributeType> typeList = (new AttributeTypeBLL()).GetAllAttributeType();
            this.ddlList.DataSource = typeList;
            this.ddlList.DataBind();

        }

        void Bind(int id)
        {
            ArtTypeBLL atbll = new ArtTypeBLL();
            Com.CMS263.PO.ArtType at = atbll.GetArtTypeById(id);
            this.typeName.Text = at.typeName;
            if (at.isShow == 1)
            {
                this.chkShow.Checked = true;
            }
            else
            {
                this.chkShow.Checked = false;
            }
             ap = at.outLink.ToString();
            this.txtOrderId.Text = at.orderId.ToString();
            this.hdfpid.Value = id.ToString();
           
           

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string typeName = StringUtil.checkStr(this.typeName.Text);


            ArtTypeBLL atbll = new ArtTypeBLL();
            Com.CMS263.PO.ArtType at = atbll.GetArtTypeById(int.Parse(this.hdfpid.Value));
            ///外部程序连接不能动，这里动了菜单就会出问题
            at.outLink =int.Parse( Request["outApp"]);
            at.typeName = typeName;
            if (this.chkShow.Checked)
            {
                at.isShow = 1;
            }
            else
            {
                at.isShow = 0;
            }
            at.orderId =int.Parse( this.txtOrderId.Text);
            atbll.Modify(at);
            //更新后台菜单

            string menu = atbll.GetTypeTree();
            FileUtil.WriteToFile(Server.MapPath("/manage/menutext/menu.txt"), menu);
            StringUtil.Alert("修改成功", "addArtType.aspx" );
        }
    }
}
